package com.easyExcel.model;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import lombok.Data;
import org.apache.commons.lang3.compare.ObjectToStringComparator;

import javax.swing.*;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 信息模型
 */

@Data
public class Model implements Serializable {
    private static final long serualVersionUID =1344L;

    @ExcelProperty(value = "订单行")
    private String line;

    @ExcelProperty(value = "物料/支付内容")
    private String paymentContents;

    @ExcelProperty(value = "物料编码")
    private String materialCode;

    @ExcelProperty(value = "物料组")
    private String materialGroup;

    @ExcelProperty(value = "阶段名称")
    private String stageName;


    @ExcelProperty(value = "任务名称")
    private String projectName;

    @ExcelProperty(value = "订单行金额")
    private String rowMoney;

    @ExcelProperty(value = "税额")
    private String  tax;

    @ExcelProperty(value = "本位币")
    private String  money;

    @ExcelProperty(value = "行已审批金额")
    private String  lineApproveMoney;

    @ExcelProperty(value = "行待审批金额")
    private String  linePendingApproveMoney;

    @ExcelProperty(value = "行已支付金额")
    private String  linePaidMoney;

    @ExcelProperty(value = "行可申请金额")
    private String  lineApplyMoney;

    @ExcelProperty(value = "是否里程碑")
    private String  isMilestone;

    @ExcelProperty(value = "申请金额")
    private String  applyMoney;

    @ExcelProperty(value = "申请时间")
    private String  applyTime;

    @ExcelProperty(value = "紧急程度")
    private String  urgency;

    @ExcelProperty(value = "备注")
    private String  notes;

    public boolean isSameOrderItem(Model model) {
        if (model == null) {
            return false;
        }
        return Objects.equals(this.line, model.getLine());
    }

    public boolean isSameIndex(Model model, String columnName)  {
        if (model == null) {
            return false;
        }
        try {
            Field field = model.getClass().getDeclaredField(columnName);
            field.setAccessible(true);
            return Objects.equals(field.get(model) == null ? "" : String.valueOf(field.get(model)),field.get(this) == null ? "" : String.valueOf(field.get(this)));
        }catch (Exception e){
              throw  new RuntimeException("导出异常");

        }

    }
}

